#define   _CRT_SECURE_NO_WARNINGS 1
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
typedef struct ListNode ListNode;
ListNode* _addTwoNumbers(ListNode* l1, ListNode* l2, int cur)
{
    int sums = cur;
    if (l1 == NULL && l2 == NULL && cur == 0)
    {
        return NULL;
    }
    else {
        if (l1 != NULL)
        {
            sums += l1->val;
            l1 = l1->next;
        }
        if (l2 != NULL)
        {
            sums += l2->val;
            l2 = l2->next;
        }
    }

    ListNode* a = (ListNode*)malloc(sizeof(ListNode));
    a->val = sums % 10;
    a->next = _addTwoNumbers(l1, l2, sums / 10);
    return a;
}
struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {
    return _addTwoNumbers(l1, l2, 0);
}